package com.pinda.controller;



import com.pinda.auth.entity.PdCoreOrg;
import com.pinda.auth.entity.PdCoreOrg;
import com.pinda.auth.view.PdCoreOrgView;
import com.pinda.commonutils.Result;
import com.pinda.commonutils.StatusCode;

import com.pinda.auth.entity.PdCoreOrg;
import com.pinda.service.IPdCoreOrgService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 组织 前端控制器
 * </p>
 *
 * @author author
 * @since 2023-06-24
 */
@RestController
@RequestMapping("/pd-core-org")
public class PdCoreOrgController {
    @Resource
    private IPdCoreOrgService iPdCoreOrgService;

    /**
     * TODO 查询所有组织，用户，地址，
     * @return Result<PdCoreOrgView>
     */
    @RequestMapping("findCoreOrgUser")
    public Result<PdCoreOrgView> findCoreOrgUser(){
        return new Result<PdCoreOrgView>(true, StatusCode.OK,"查询成功",this.iPdCoreOrgService.findCoreOrgUserService());
    }

    /**
     * TODO 新增组织
     * @param pdCoreOrg
     * @return
     */
    @RequestMapping("addOrganization")
    public Result<Boolean> addOrganization(@RequestBody PdCoreOrg pdCoreOrg){
        return new Result<Boolean>(true, StatusCode.OK,"新增成功",this.iPdCoreOrgService.save(pdCoreOrg));
    }

    @RequestMapping("findcoreOrg")
    public List<PdCoreOrg> findcoreOrg(){
       return iPdCoreOrgService.list();
    }

    @RequestMapping("jgfanweistate")
    public void  jgfaweistate(@RequestBody PdCoreOrg  pdOrg){
        System.out.println("----------------------------"+pdOrg);

        this.iPdCoreOrgService.jgfaweistate(pdOrg);
    }

    /**
     * TODO 删除组织
     * @param id
     * @return Result<Boolean>
     */
    @RequestMapping("removeOrganization/{id}")
    public Result<Boolean> removeOrganization(@PathVariable("id") String id){
        return new Result<Boolean>(true, StatusCode.OK,"删除成功",this.iPdCoreOrgService.removeById(id));
    }

    /**
     * TODO 编辑组织
     * @param pdCoreOrg
     * @return Result<Boolean>
     */
    @RequestMapping("updateOrganization")
    public Result<Boolean> updateOrganization(@RequestBody PdCoreOrg pdCoreOrg){
        return new Result<Boolean>(true, StatusCode.OK,"修改成功",this.iPdCoreOrgService.updateById(pdCoreOrg));
    }

    @GetMapping("/latitudeAndLongitude/{id}")
    public PdCoreOrg latitudeAndLongitude(@PathVariable("id") long id){
        return iPdCoreOrgService.latitudeAndLongitude(id);
    }

}
